// views/index/shop/mailservice/second/index.js
var BASE_URL = getApp().globalData.BASE_URL
var area = require('../../../../../utils/area');
var util = require('../../../../../utils/util');

import Notify from '../../../../../miniprogram_npm/@vant/weapp/notify/notify';

Page({

  /**
   * 页面的初始数据
   */
  data: {
    name: '',
    pinyin: '',
    telNumber: '',
    iban: '',
    bic: '',
    kontonummer: '',
    bankleitzahl: '',
    firma: '',
    verwendungszweck: '',
    number: '',
    email: '',
    wechat_num: '',
    huilv: "",
    euro_price: 0,
    fuwufei: 0,
    amount: 0,
    ifma: false,
    ifhao: false,
    id: ''
  },















  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id: options.id
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var _this = this
    if (util.iflogin()) {
      var userinfo = wx.getStorageSync("USER")
      this.setData({
        email: userinfo.email
      })
      _this.gethuilv()
      _this.getorderdetail()
    }
  },
  //获得汇率
  getorderdetail: function () {
    var userinfo = wx.getStorageSync("USER")
    var _this = this
    wx.request({
      url: `${BASE_URL}/daihui/info`,
      method: "GET",
      data: {
        type: 'xiaochengxv',
        uid: userinfo.id,
      },
      header: {
        'Content-Type': 'application/json' //GET方式是这个
      },
      success(res) {
        console.log(res)
        _this.setData({
          name: res.data.list.name,
          pinyin: res.data.list.pinyin,
          telNumber: res.data.list.telNumber,
          iban: res.data.list.iban,
          bic: res.data.list.bic,
          kontonummer: res.data.list.kontonummer,
          bankleitzahl: res.data.list.bankleitzahl,
          firma: res.data.list.firma,
          verwendungszweck: res.data.list.verwendungszweck,
          number: res.data.list.number,
          email: res.data.list.email,
          wechat_num: res.data.list.wechat_num,
          fuwufei: Math.ceil(res.data.list.number / 50) * 5,
          amount: res.data.list.zong,
        })
      }
    })
  },




  //获得汇率
  tijaoorder: function () {
    var _this = this
    var userinfo = wx.getStorageSync("USER")
    wx.request({
      url: `${BASE_URL}/daihui/order`,
      method: "GET",
      data: {
        type: 'xiaochengxv',
        uid: userinfo.id,
        id: _this.data.id
      },
      header: {
        'Content-Type': 'application/json' //GET方式是这个
      },
      success(res) {
        console.log(res)
        wx.navigateTo({
          url: `../../visahandle/paypage/index?id=${res.data.id}`,
        })
      }
    })
  },
  gethuilv: function () {
    var _this = this
    wx.request({
      url: `${BASE_URL}/daihui/huilv`,
      method: "GET",
      header: {
        'Content-Type': 'application/json' //GET方式是这个
      },
      success(res) {
        console.log(res)
        _this.setData({
          huilv: res.data
        })
      }
    })
  },







})